package metier;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

import jdbc.Connexion;
import metier.jdbc.GradeJdbc;
import configuration.Constante;

public class Eleve {
	
	// Attributs
	private Integer idEleve;
	private String nomEleve;
	private String prenom;
	private Date dateNaissance;
	private Integer idGrade;
	private Integer idStage;
	private Integer idFonction;
	
	// Constructeur
	public Eleve(Integer idEleve, String nomEleve, String prenom,
			Date dateNaissance, Integer idGrade, Integer idStage,
			Integer idFonction) {
		
		this.idEleve = idEleve;
		this.nomEleve = nomEleve;
		this.prenom = prenom;
		this.dateNaissance = dateNaissance;
		this.idGrade = idGrade;
		this.idStage = idStage;
		this.idFonction = idFonction;
	}
	
	/**
	 * @return
	 */
	public Vector<Object> getVector(){
		SimpleDateFormat sdf = new SimpleDateFormat(Constante.FORMAT_DATE_SHORT);
		Vector<Object> vector = new Vector<Object>();
		vector.add(this.getIdEleve().toString());
		vector.add(this.getNomEleve());
		vector.add(this.getPrenom());
		// Recherhce du libelle grade.
		String abrev = GradeJdbc.getAbrevGradeById(Connexion.getConnexion(), this.idGrade);
		vector.add(abrev);
		if (this.getDateNaissance() == null){
			vector.add("");
		}else{
			vector.add(sdf.format(this.getDateNaissance()));
		}
		return vector;
	}
	
	// Getters & Setters
	public Integer getIdEleve() {
		return idEleve;
	}
	public void setIdEleve(Integer idEleve) {
		this.idEleve = idEleve;
	}
	public String getNomEleve() {
		return nomEleve;
	}
	public void setNomEleve(String nomEleve) {
		this.nomEleve = nomEleve;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	public Date getDateNaissance() {
		return dateNaissance;
	}
	public void setDateNaissance(Date dateNaissance) {
		this.dateNaissance = dateNaissance;
	}
	public Integer getIdGrade() {
		return idGrade;
	}
	public void setIdGrade(Integer idGrade) {
		this.idGrade = idGrade;
	}
	public Integer getIdStage() {
		return idStage;
	}
	public void setIdStage(Integer idStage) {
		this.idStage = idStage;
	}
	public Integer getIdFonction() {
		return idFonction;
	}
	public void setIdFonction(Integer idFonction) {
		this.idFonction = idFonction;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Eleve [idEleve=" + idEleve + ", nomEleve=" + nomEleve
				+ ", prenom=" + prenom + ", dateNaissance=" + dateNaissance
				+ ", idGrade=" + idGrade + ", idStage=" + idStage
				+ ", idFonction=" + idFonction + "]";
	}
}
